import { SelectControlSchema } from 'amis/lib/renderers/Form/Select'
import amisUtils from '@/components/amis/amisUtils'
import Oauth2RegisteredClientRestGrantTypeRestGrantTypeEnum from '@/core/oauth2/enums/Oauth2RegisteredClientRestGrantTypeRestGrantTypeEnum'

class RestGrantTypeSelectUtils {
	getSchema = (parmas?: SelectControlSchema): SelectControlSchema => {
		const name = parmas?.name ? parmas.name : 'restGrantType'
		const mergeSchema = Object.assign(
			{
				name: name,
				type: 'select',
				label: '认证方式',
				clearable: true,
				options: amisUtils.getSelectOptionsFromBaseEnumValues(
					Oauth2RegisteredClientRestGrantTypeRestGrantTypeEnum.CLIENT_CREDENTIALS,
					Oauth2RegisteredClientRestGrantTypeRestGrantTypeEnum.USERNAME,
					Oauth2RegisteredClientRestGrantTypeRestGrantTypeEnum.WX_MINI_APP_LOGIN_CODE,
					Oauth2RegisteredClientRestGrantTypeRestGrantTypeEnum.WX_MINI_APP_PHONE_CODE,
					Oauth2RegisteredClientRestGrantTypeRestGrantTypeEnum.DEFAULT,
				),
			},
			parmas,
		)

		const schema = mergeSchema
		return schema
	}
}

export default new RestGrantTypeSelectUtils()
